<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>重置密码</title>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/weChat/css/style.css"/>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/weChat/css/reset.css"/>

	</head>
	<body>
		<div class="wrapper">
		    <div class="header_bank_cash">
		        <div class="con_header_tu">
		            <img src="<?php echo empty($result['avatar']) ? '__PUBLIC__/weChat/images/u=620043864,3105064494&fm=21&gp=0.jpg':$result['avatar']?>" class="head_jpg" alt=""><br/>
		            <span class="con_h_span"><?php echo empty($result['username']) ? '':substr($result['username'], 0, 3).'****'.substr($result['username'],7,9);?></span>
		        </div>
		    </div>
		    <div class="content_modify_1">
		        <div class="con_m_pas b_btm" >
		            <span class="con_m_left font1">旧密码:</span>
		            <input type="password" class="font4 ww" style="border:0" placeholder="请输入旧密码" name="password" >
		        </div>
		        <div class="con_m_pas b_btm" >
		            <span class="con_m_left font1">新密码 :</span>
		            <input type="password" class="font4 ww" id="pas2"   style="border:0" placeholder="请输入新密码" name="newpassword" >
		        </div>
		        <div class="con_m_pas b_btm" >
		            <span class="con_m_left font1">重复密码 :</span>
		            <input type="password" class="font4 ww" id="pas3"   style="border:0" placeholder="请重复新密码" name="repeatpassword" >
		        </div>
		        <div class="con_m_pas b_btm" >
		            <span class="con_m_left font1">验证码 :</span>
		            <input type="text " class="c_m_inp font4 ww" maxlength="6"  id="pas4" placeholder="请输入验证码"  onkeyup='this.value=this.value.replace(/\D/gi,"")' name="verificationCode">
		            <div class="get_yz dis_in">
		                <button type="button "  id="getting"  value="">获取验证码</button>
		            </div>
		        </div><!--passw_box-->
				<div class="con_m_pas b_btm"  id="suc" style="display: none">
					<img src=""  class="icon_gth" alt="">
					<span class="con_m_left font1" id="sucmsg"></span>
				</div>
		    </div><!--content_modify_1-->
		    <div class="footer_modify ">
		        <button class="f_m_btn" id="btn3"  onclick="submit_()" >保存修改</button>
		    </div>
		</div><!--wrapper-->
		<script src="__PUBLIC__/weChat/js/base.js" type="text/javascript" charset="utf-8"></script>
		<script src="__PUBLIC__/weChat/js/jquery-2.2.2.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//获取验证码
			var clock = '';
			var times = 60;
			$("#getting").on("click", function () {
				if($(this).html()=="获取验证码"){
					sendCode(this);
				}
			});

			function sendCode(thisBtn) {
				$.ajax({
					type:'post',
					url:"<?php echo url('Person/sendCode')?>",
					data:{},
					success:function(data){
						if(data.code == 0){
							$("#getting").html(times+'秒后获取');
							clock = setInterval(doLoop, 1000); //一秒执行一次
							console.log('发送成功');
						} else {
							console.log('发送失败');
						}
					}
				});
			}
			function doLoop() {
				times--;
				if(times > 0){
					$("#getting").html(times+'秒后获取');
				}else{
					clearInterval(clock); //清除js定时器
					$("#getting").html('获取验证码');
					times = 60; //重置时间
				}
			};
			function submit_(){
				var password = $("input[name='password']").val();
				var newpassword = $("input[name='newpassword']").val();
				var repeatpassword = $("input[name='repeatpassword']").val();
				var verificationCode = $("input[name='verificationCode']").val();
				$.ajax({
					type:'post',
					url:"<?php echo url('Person/password')?>",
					data:{"password":password,"newpassword":newpassword,"repeatpassword":repeatpassword,"verificationCode":verificationCode},
					success:function(data){
						if(data.code == 0){
							location.href = "<?php echo url('Index/index')?>";
						}else{
							console.log('修改失败');
						}
					}
				});
			}
		</script>
	</body>
</html>
